package com.example.service.service

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import android.util.Log

class OneService : Service() {
    companion object{
        private const val TAG = "OneService"
    }
    override fun onCreate() {
        super.onCreate()
        Log.d(TAG, "onCreate: ")
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d(TAG, "onStartCommand: ")
//        startForeground(101,notificatioon) 前台服务，通知形式
        return super.onStartCommand(intent, START_FLAG_REDELIVERY, startId)
    }

    override fun onDestroy() {
        Log.d(TAG, "onDestroy: ")
        super.onDestroy()
    }
    override fun onBind(intent: Intent): IBinder {
        Log.d(TAG, "onBind: ")
        return OneBinder()
    }
    override fun onUnbind(intent: Intent?): Boolean {
        Log.d(TAG, "onUnbind: ")
        return super.onUnbind(intent)
    }
    /**
     * 代理
     */
    inner class OneBinder:Binder(){
        fun add(num1:Int,num2:Int):Int{
            return num1+num2
        }

    }


}